package com.winit.openapi.interceptor.validator.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.winit.openapi.interceptor.validator.OAuth2APIRequestValidator;
import com.winit.openapi.util.ValidateUtil;

@Service("oAuth2ClientRequestHandler")
public class OAuth2ClientRequestHandler extends OAuth2APIRequestValidator<HttpServletRequest> {

    @Override
    public void doAuth(HttpServletRequest request) {
        checkClient(request);
        checkClientSign(request);

    }

    @Override
    public void doCheckData(HttpServletRequest request) {
        JSONObject json = super.checkBaseData(request);
        ValidateUtil.validNotNull(json, "client_id");
        ValidateUtil.validMaxLength(json, "client_id", 120);
        ValidateUtil.validNotNull(json, "client_sign");
        ValidateUtil.validMaxLength(json, "client_sign", 32);
        ValidateUtil.validNotNull(json, "platform");
        ValidateUtil.validMaxLength(json, "platform", 50);

    }

}
